package cosw.com.shanghaica;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.cosw.sdkShanghaiCA.EnumError;
import com.cosw.sdkShanghaiCA.SHCAProvider;

public class ResetPinActivity extends ActionBarActivity {

  @BindView(R.id.tv_confirm)
  Button tvConfirm;
  @BindView(R.id.tv_old_pin)
  TextView tvOldPin;
  @BindView(R.id.tv_new_pin)
  TextView tvNewPin;
  @BindView(R.id.et_old_pin)
  EditText etOldPin;
  @BindView(R.id.et_new_pin)
  EditText etNewPin;

  private SHCAProvider provider;

  private Context mContext;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_reset_pwd);
    ButterKnife.bind(this);

    mContext = this;

    provider = SHCAProvider.getInstance(this.getApplication());
  }

  @OnClick(R.id.tv_confirm)
  public void onViewClicked() {
    String oldAdminPin = etOldPin.getText().toString();
    String newAdminPin = etNewPin.getText().toString();
    int result = provider.modifyAdminPin(oldAdminPin, newAdminPin);
    if (result == 1)
        Toast.makeText(mContext, "执行成功", Toast.LENGTH_SHORT).show();
    else
      Toast.makeText(mContext, "执行失败", Toast.LENGTH_SHORT).show();
  }
}
